home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
magazyn_amiga
/
6
/
ami013a_komputerowa_hodowla.li
< prev
next >
Wrap
Text File
|
1997-09-16
|
2KB
|
183 lines
/* listing nr 1 */
#include <intuition/intuition.h>
#include <functions.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define WIDTH 640
#define HEIGHT 256
#define x0 10
#define y0 210
struct Window *wind1;
struct Window *wind2;
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct NewWindow wind1_data={
0,0,WIDTH,HEIGHT,1,1,CLOSEWINDOW,
ACTIVATE|GIMMEZEROZERO|WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH,
0,0,(UBYTE *)"Zmiana iloôci w czasie",0,0,
200,256,WIDTH,HEIGHT,WBENCHSCREEN};
struct NewWindow wind2_data={
0,256,WIDTH,HEIGHT,1,1,CLOSEWINDOW,
ACTIVATE|GIMMEZEROZERO|WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH,
0,0,(UBYTE *)"Stosunek iloôci",0,0,
200,256,WIDTH,HEIGHT,WBENCHSCREEN};
void koniec(void)
{
if (wind1) CloseWindow(wind1);
if (wind2) CloseWindow(wind2);
if (GfxBase)
CloseLibrary((struct Library *)GfxBase);
if (IntuitionBase)
CloseLibrary((struct Library *)IntuitionBase);
exit(0);
}
void OpenAllLibraries(void)
{
IntuitionBase=(struct IntuitionBase *)
OldOpenLibrary("intuition.library");
if (!IntuitionBase) exit(100);
GfxBase=(struct GfxBase *)
OldOpenLibrary("graphics.library");
if (!GfxBase) exit(100);
}
int x(int X)
{
return(X+x0);
}
int y(int Y)
{
return(y0-Y);
}
main(int argc,char *argv[])
{
float scale=WIDTH/20000.0;
int t; /* czas */
float w,k; /* wilki i króliki */
float w1,k1; /* zmiany liczebnoôci */
if(argc!=3)
{
printf("Argumenty: w k\n");
exit(0);
}
OpenAllLibraries();
if(!(wind1=OpenWindow(&wind1_data))) koniec();
if(!(wind2=OpenWindow(&wind2_data))) koniec();
Move(wind1->RPort,x(0),y(0));
Draw(wind1->RPort,x(0),y(200));
Move(wind1->RPort,x(0),y(0));
Draw(wind1->RPort,x(620),y(0));
Move(wind2->RPort,x(0),y(0));
Draw(wind2->RPort,x(0),y(200));
Move(wind2->RPort,x(0),y(0));
Draw(wind2->RPort,x(620),y(0));
w = atof(argv[1]);
k = atof(argv[2]);
for(t=1;t<20000;t++)
{
SetAPen(wind1->RPort,1);
WritePixel(wind1->RPort,x((int)(t*scale)), y((int)(w/15.0)));
SetAPen(wind1->RPort,2);
WritePixel(wind1->RPort,x((int)(t*scale)), y((int)(k/15.0)));
SetAPen(wind2->RPort,1);
WritePixel(wind2->RPort,x((int)(k/10.0)), y((int)(w/10.0)));
w1=w-0.002*w+0.000002*w*k;
k1=k-0.00002*w*k+0.002*k;
w=w1;
k=k1;
}
Wait(1<<wind1->UserPort->mp_SigBit);
koniec();
}